//
//  HomeCell.m
//  WXMovie
//
//  Created by apple on 16/3/30.
//  Copyright © 2016年 zic_magic. All rights reserved.
//

#import "HomeCell.h"

@implementation HomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setModel:(HomeModel *)model {
    
    _model = model;
    self.titleLabel.text = _model.title;
    self.yearLabel.text = [NSString stringWithFormat:@"年份:%@", _model.year];
    self.ratingLabel.text = [NSString stringWithFormat:@"%.1f", [_model.rating[@"average"] floatValue]];
    
    NSString *imageUrl = _model.images[@"large"];
    
//    self.imgView.image = [UIImage imageNamed:@"pig"];
//    if ([UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]]) {
//        
//        self.imgView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
//}
    

    _width.constant = kScreenWidth / 3 * 90 /134;
    
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"pig"]];
    [_starView changeStarViewWidthWithRating:[self.ratingLabel.text floatValue]];
    
    
    
    
}

@end
